<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="static/style/images/favicon.ico" />
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>用户管理</title>
<script type="text/javascript">

    var dataGrid;
    var flag = 1;

    $(function () {
 	    //用户维护（新增、修改）界面
        $("#importDialog").dialog({
            title: "新增",
            width: 600,
            height: 400,
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    saveUser();
                }
            }, {
                text: '关闭',
                handler: function () {

                    $("#importDialog").dialog("close");
                }
            }]
        });
        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/pricelist',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            singleSelect: true,
            idField: 'id',
            columns: [[{
                width: '20%',
                title: ' id',
                field: 'id',
                hidden: true
            }, {
                width: '40%',
                title: ' 类型',
                field: 'order_type'
            },{
                width: '30%',
                title: ' 原价',
                field: 'price'
            },{
                width: '30%',
                title: ' 优惠价',
                field: 'youhui_price'
            }, ]],
            toolbar: '#toolbar'
        });
        });


        //修改
        function editFun() {
			 var rows= dataGrid.datagrid('getSelected');

				if(rows == "undefined"||rows == null){
					HdUtil.messager.info("请选中编辑行");
					return;
				}
		        //= dataGrid.datagrid('getSelected');
                // id = rows.id;

            $("#userForm").form("clear").form("load", rows);
            $("#importDialog").dialog("open");
        }

        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }

        //保存
        function saveUser() {
            $("#userForm").form("submit", {
                url: "/updateprice",
                onSumbit: function () {
                    $("#userForm").form.validate();
                },
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#importDialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#importDialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }

    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
<div data-options="region:'north',border:false" style="height: 30px; overflow: hidden;background-color: #fff">
  <form id="searchForm">
    <table>
      <tr>
        <td>
          <td><a onclick="editFun();" href="javascript:void(0);" class="easyui-linkbutton"
                 data-options="plain:true,iconCls:'icon-edit'">编辑</a></td>
      </tr>
    </table>
  </form>

</div>
<div data-options="region:'center',border:true,title:'信息列表'">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>

<div id="importDialog">
    <form id="userForm" method="post">
        <table>
            <tr>
                <input  name="order_type" type="hidden" />
                <td style="vertical-align: middle">原价：</td>
                <td>
                   <input  name="price" type="text" />
                </td>

                <td style="vertical-align: middle">原价：</td>
                <td>
                   <input  name="youhui_price" type="text" />
                </td>

            </tr>

        </table>
    </form>
</div>

</body>
</html>
